<!DOCTYPE html>
<html lang="ch">
<head>
    <meta charset="UTF-8">
    <title>文件上传案例</title>
    <link href="css/iconfont.css" rel="stylesheet" type="text/css"/>
    <link href="css/fileUpload.css" rel="stylesheet" type="text/css">
</head>
<body>
    <!--创建一个文件上传的容器-->
    <div id="fileUploadContent" class="fileUploadContent"></div>
    <button onclick="success()">模拟上传成功</button><button onclick="fail()">模拟上传失败</button>
    <br/>
    <br/>
    <br/>
    <br/>
    <a href="doc.html">文档说明</a>
</body>
</html>
<script src="http://www.jq22.com/jquery/jquery-2.1.1.js"></script>
<script type="text/javascript" src="js/fileUpload.js"></script>
<script type="text/javascript">
    let wfu = new WpFileUpload("fileUploadContent");
    wfu.initUpload({
        "uploadUrl":"http://jk.cn/test",//上传文件信息地址
        "progressUrl":"#",//获取进度信息地址，可选，注意需要返回的data格式如下（{bytesRead: 102516060, contentLength: 102516060, items: 1, percent: 100, startTime: 1489223136317, useTime: 2767}）
        "scheduleStandard":false, //false真实上传，true模拟上传
        "maxFileNumber":1 , //控制文件上传个数
        // "isAutoClean":true, //上传完成自动清除
        // "showSummerProgress":false, //关闭总进度条显示
        "uploadFileParamIteration":true,  //PHP设置上传的文件参数是否迭代，如果true：files0，files1，files2...... 
        "onUpload":'onUpload',
        "fileType":'jpg'
    });

    //显示文件，设置删除事件
    // wfu.showFileResult("img/a2.png","1",null,true,true,deleteFileByMySelf,downloadByMySelf);
    // //如果不需要删除
    // wfu.showFileResult("img/a3.png","2",null,false,false,null,null);
    //多文件需要自己进行循环
    function deleteFileByMySelf(fileId){
        alert("要删除文件了："+fileId);
        wfu.removeShowFileItem(fileId);
    }


    /**
     * 上传完成操作
     * */
		function doSuccess(response){
          console.log(response);
	
		}
        
        /**
         * 文件格式错误回调
         * */
		function fileFail(msg){
        
			console.log(msg)
		}

		function downloadByMySelf(fileId, url) {
            alert(url)
        }

        function onUpload(){

            alert(1);
        }

</script>